package com.maxd.respository.timedTask;

import com.maxd.model.TimedTask;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface TimedTaskRepository extends Repository<TimedTask, Long> {

    @Query(value = "select * from timed_task s where now()>=s.end_time ",nativeQuery = true)
    List<TimedTask> selectEndTime();

    @Transactional
    @Modifying
    @Query(value = "delete from timed_task where object_id=:ObjectId and `type`=:type ",nativeQuery = true)
    Integer deleteByObjectId(@Param("ObjectId") Long ObjectId,@Param("type")  Integer type);

}